unit UnitCadModelo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, DBCtrls, Mask, DB, ADODB,
  jpeg;

type
  TFormCadModelo = class(TForm)
    Panel3: TPanel;
    btAnterior: TBitBtn;
    btProxima: TBitBtn;
    btOK: TBitBtn;
    btCancelar: TBitBtn;
    pcDados: TPageControl;
    GroupBox1: TGroupBox;
    Splitter2: TSplitter;
    pnCabecalho: TPanel;
    Image1: TImage;
    procedure btAnteriorClick(Sender: TObject);
    procedure btProximaClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure pcDadosChange(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormCadModelo: TFormCadModelo;

implementation

{$R *.dfm}

procedure TFormCadModelo.btAnteriorClick(Sender: TObject);
begin
  Repeat
    if pcDados.ActivePageIndex > 0 then
      pcDados.ActivePageIndex := pcDados.ActivePageIndex-1;
    btAnterior.Enabled := (pcDados.ActivePageIndex > 0);
    btProxima.Enabled := (pcDados.ActivePageIndex < pcDados.PageCount-1);
  Until pcDados.ActivePage.TabVisible;
end;

procedure TFormCadModelo.btProximaClick(Sender: TObject);
begin
  Repeat
    if pcDados.ActivePageIndex < pcDados.PageCount-1 then
      pcDados.ActivePageIndex := pcDados.ActivePageIndex+1;
    btProxima.Enabled := (pcDados.ActivePageIndex < pcDados.PageCount-1);
    btAnterior.Enabled := (pcDados.ActivePageIndex > 0);
  Until pcDados.ActivePage.TabVisible;
end;

procedure TFormCadModelo.FormShow(Sender: TObject);
begin
  btAnterior.Enabled := (pcDados.ActivePageIndex > 0);
  btProxima.Enabled := (pcDados.ActivePageIndex < pcDados.PageCount-1);
end;

procedure TFormCadModelo.pcDadosChange(Sender: TObject);
begin
  btAnterior.Enabled := (pcDados.ActivePageIndex > 0);
  btProxima.Enabled := (pcDados.ActivePageIndex < pcDados.PageCount-1);
end;

procedure TFormCadModelo.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
    Perform(WM_NEXTDLGCTL, 0, 0);
end;

procedure TFormCadModelo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  if ModalResult=mrAbort then
    Action := caNone;
end;

end.
